package com.doyens.controller;

import com.doyens.pojo.Student;
import com.doyens.pojo.Teacher;
import com.doyens.service.StudentService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {
    @Resource
    private StudentService studentService;

    @RequestMapping("/findAll.do")
    @ResponseBody
    public PageInfo<Student> findAll(Integer pageNum){
        return studentService.findAllStu(pageNum);
    }

    @RequestMapping("/findById.do")
    @ResponseBody
    public Student findById(Integer id){
        return studentService.findById(id);
    }

    @RequestMapping("/delete.do")
    @ResponseBody
    public Integer delete(Integer id){
        return studentService.delete(id);
    }

    @RequestMapping("/update.do")
    @ResponseBody
    public Integer update(Student student){
        return studentService.update(student);
    }

    @PostMapping("/save.do")
    @ResponseBody
    public int save(Student student){
        return studentService.save(student);
    }
}
